import request from '@/config/axios'

// 公开墙消息 VO
export interface WallMessageVO {
  id?: number // 编号
  createTime?: string // 创建时间
  content: string // 消息内容
  category?: string // 消息分类：technical、business、complaint
  author?: string // 发布者
  version?: string // 版本
  likes?: number // 点赞数
}

// 公开墙消息分页查询参数
export interface WallMessagePageReqVO {
  pageNo?: number
  pageSize?: number
  createTime?: string[]
  content?: string
  category?: string
  author?: string
  version?: string
  likes?: number
}

// 公开墙消息 API
export const WallMessageApi = {
  // 查询公开墙消息分页
  getWallMessagePage: async (params: WallMessagePageReqVO) => {
    return await request.get({ url: `/agent/wall-message/page`, params })
  },

  // 查询公开墙消息详情
  getWallMessage: async (id: number) => {
    return await request.get({ url: `/agent/wall-message/get?id=` + id })
  },

  // 新增公开墙消息
  createWallMessage: async (data: WallMessageVO) => {
    return await request.post({ url: `/agent/wall-message/create`, data })
  },

  // 修改公开墙消息
  updateWallMessage: async (data: WallMessageVO) => {
    return await request.put({ url: `/agent/wall-message/update`, data })
  },

  // 删除公开墙消息
  deleteWallMessage: async (id: number) => {
    return await request.delete({ url: `/agent/wall-message/delete?id=` + id })
  },

  // 导出公开墙消息 Excel
  exportWallMessage: async (params: WallMessagePageReqVO) => {
    return await request.download({ url: `/agent/wall-message/export-excel`, params })
  },

  // 点赞消息（自定义方法，可能需要后端支持）
  likeWallMessage: async (id: number) => {
    // 这里可以调用更新接口来增加点赞数
    // 或者后端提供专门的点赞接口
    return await request.put({ url: `/agent/wall-message/like?id=` + id })
  }
}
